package duxiaoman.d20211023.t1;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @author habitplus
 * @since 2021-10-23 11:35
 */
public class Main {
//    static final StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
//
//    static int nextInt() {
//        try {
//            st.nextToken();
//            return (int) st.nval;
//        } catch (IOException e) {
//            throw new RuntimeException("input is invalid!");
//        }
//    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String companyName = br.readLine();
        String str = br.readLine();

        int[] res = solve(companyName, str);
        System.out.println(res[0] + " " + res[1]);

    }

    private static int[] solve(String cName, String str) {
        if (cName == null || str == null || str.length() < 1 )
            return new int[]{0, 0};

        char[] strChs = str.toCharArray();
        int[] strAlpha = getTable(strChs);
        int rest = 0;
        if (cName.length() < 1) {
            for (int i = 0; i < strAlpha.length; i++) {
                if (strAlpha[i] > 0) {
                    rest++;
                }
            }
            return new int[]{0, rest};
        }

        int maxCnt = Integer.MAX_VALUE, t;
        char[] chs = cName.toCharArray();
        int[] alpha = getTable(chs);

        for (int i = 0; i < alpha.length; i++) {
            if (alpha[i] < 1) continue;
            if (strAlpha[i] < 1 || strAlpha[i] < alpha[i]) {
                maxCnt = 0;
                break;
            }
            t = strAlpha[i] / alpha[i];
            maxCnt = Math.min(maxCnt, t);
        }

        for (int i = 0; i < strAlpha.length; i++) {
            if (alpha[i] > 0) {
                strAlpha[i] -= maxCnt * alpha[i];
            }

            if (strAlpha[i] > 0) rest++;
        }

        return new int[]{maxCnt, rest};
    }

    private static int[] getTable(char[] chs) {
        int[] res = new int[52];
        for (int i = 0; i < chs.length; i++) {
            if (chs[i] >= 'a' && chs[i] <= 'z') {
                res[chs[i] - 'a' + 26]++;
            } else {
                res[chs[i] - 'A']++;
            }
        }
        return res;
    }
}
